<?php

use App\Models\ConfigGood;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateConfigGoodsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('config_goods', function (Blueprint $table) {
            $table->id();
            $table->decimal('goods_total_price', 10, 2)->default(1000)->comment('可抢购商品总价');
            $table->unsignedInteger('goods_incr_percent')->default(125)->comment('商品增长比例');
            $table->time('start_at')->default('18:00');
            $table->time('end_at')->default('22:00');
            $table->unsignedInteger('destory_time')->default('300')->comment('未付款过期时间');
            $table->decimal('user_quota', 10, 2)->default(1000)->comment('用户可抢额度');
            $table->unsignedInteger('lowest_amount_percent')->default(95)->comment('红包最小比例');
            $table->unsignedInteger('highest_amount_percent')->default(99.99)->comment('红包最大比例');
            $table->timestamps();
        });

        ConfigGood::create(['goods_total_price' => 1000]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('config_goods');
    }
}
